package ru.compft.site.spring.utils;

import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import ru.compft.web.utils.MessageCreator;

import javax.annotation.Resource;

/**
 * User: ASUS
 * Date: 20.10.12
 * Time: 10:01
 */
@Component("messageCreator")
// todo удалить совсем. использовать messageSource напрямую
public class SpringMessageCreatorImpl implements MessageCreator {

    @Resource(name = "messageSource")
    private MessageSource messageSource;

    @Override
    public void addErrorMessage(String msg) {
        System.out.println("ErrorMessage = " + msg);
        final String message = messageSource.getMessage(msg, null, LocaleContextHolder.getLocale());
        System.out.println("ErrorMessage from MessageSource = " + message);
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
